<!DOCTYPE html >
<html>
<head>
    <meta charset="utf-8">
    <title>handlebar测试</title>




<!-- 加载模板 -->
<script type="text/javascript">
    function loadData()
    {
        var  source = document.getElementById("handlebar01").innerHTML;
        var  template = Handlebars.compile(source);
        var json = [{name:"张三",age:24,companyName:"第一公司"}
                    ,{name:"李四",age:34,companyName:"第二公司"}
                    ,{name:"王五",age:44,companyName:"第三公司"}];
        var  html = (template(json));
        document.getElementById("context").innerHTML = html;
    }
</script>
</head>
<body onload="loadData()">

<div id="context">
<!-- 模板 -->
<script id="handlebar01" type="text/x-handlebars-template">
    {{#each this}}
    <ul>
        <li>{{this.name}}</li>
        <li>{{this.age}}</li>
        <li>{{this.companyName}}</li>
    </ul>
    {{/each}}
</script>
</div>
</body>
</html>
